#include "stdio.h"
#include "stdlib.h"
int main()
{
    char str[100];
    int i, j, score[10], sum;
    gets(str);
    i = 0;
    j = 0;
    while(str[i]) 
    {
        while(str[i]==' ')i++;
        if(str[i]=='A'&&(str[i+1]==' '||str[i+2]=='\0'))    //A
        {
         score[j++]=11;
  }
        else if(str[i]>='2'&&str[i]<='9'&&(str[i+1]==' '||str[i+1]=='\0'))   //2-9
        {
            score[j++]=str[i]-'0';
        }
        else if(str[i]=='1'&&str[i+1]=='0'&&(str[i+2]==' '||str[i+2]=='\0'))    //10
        {
         i++;   //i指向'0'
            score[j++]=10;
        }
        else if((str[i]=='J'||str[i]=='j'||str[i]=='Q'||str[i]=='q'||str[i]=='K'||str[i]=='k')&&(str[i+1]==' '||str[i+1]=='\0'))  //JQK
  {
            score[j++]=10;
        }
        else break;
        i++;
        if(j>=3)break;
    }
    if(j!=3)printf("input error!\n");
    else
    {
     sum=0;
     for(i=0;i<j;i++)sum+=score[i];
     if(sum>21)
     {
      for(i=0;i<j;i++)
         {
             if(score[i]==11){
              score[i]=1; 
              sum=sum-10;
    }
    if(sum<=21) break;
         }
     }
     printf("%d\n",sum);
    }
    return 0;
}